package com.sxc;

import com.sxc.bean.Message1;
import com.sxc.bean.MessagePlus;
import jakarta.xml.bind.JAXBContext;
import jakarta.xml.bind.JAXBException;
import jakarta.xml.bind.Unmarshaller;

import java.io.File;

/**
 * Hello world!
 *
 */
public class App 
{
    public static void main( String[] args ) throws JAXBException {
        System.out.println( "Hello World!" );
        //转化为列表
//        JAXBContext context = JAXBContext.newInstance(Message.class);
//        Unmarshaller unmarshaller = context.createUnmarshaller();
//        Message message = (Message) unmarshaller.unmarshal(new File("D:\\code\\java\\jaxb\\src\\main\\resources\\test.xml"));
        //转换为列表1
//        JAXBContext context = JAXBContext.newInstance(Message1.class);
//        Unmarshaller unmarshaller = context.createUnmarshaller();
//        Message1 message = (Message1) unmarshaller.unmarshal(new File("D:\\code\\java\\jaxb\\src\\main\\resources\\test.xml"));
        //转换为bean
        JAXBContext context = JAXBContext.newInstance(MessagePlus.class);
        Unmarshaller unmarshaller = context.createUnmarshaller();
        MessagePlus message = (MessagePlus) unmarshaller.unmarshal(new File("D:\\code\\java\\jaxb\\src\\main\\resources\\test.xml"));
        System.out.println(message);
    }
}
